package com.ruoyi.waterManagement.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.business.waterManagement.StationPicR;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.waterManagement.service.IStationPicRService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 测站实时图片Controller
 * 
 * @author hwd
 * @date 2023-03-02
 */
@RestController
@RequestMapping("/StationPicR")
public class StationPicRController extends BaseController
{
    @Autowired
    private IStationPicRService stationPicRService;



    /**
     * 查询视频监拍测站列表
     */
    @RequiresPermissions("waterManagement:StationPicR:list")
    @DataScope(organAlias = "organb")
    @GetMapping("/cameraStationPicRList")
    public TableDataInfo cameraStationPicRList(StationPicR stationPicR)
    {
        startPage();
        List<StationPicR> list = stationPicRService.cameraStationPicRList(stationPicR);
        return getDataTable(list);
    }

    /**
     * 通过测站代码和时间查询视频监拍测站列表
     */
    @ApiOperation("通过测站代码和时间查询视频监拍测站列表")
    @GetMapping("/cameraStationPicRByStatCdAndDate")
    public TableDataInfo cameraStationPicRByStatCdAndDate(String statCd, Date selTime) {
        List<StationPicR> stationPicRList = stationPicRService.cameraStationPicRByStatCdAndDate(statCd, selTime);
        return getDataTable(stationPicRList);
    }

    /**
     * 查询测站实时图片列表
     */
    @RequiresPermissions("waterManagement:StationPicR:list")
    @GetMapping("/list")
    public TableDataInfo list(StationPicR stationPicR)
    {
        startPage();
        List<StationPicR> list = stationPicRService.selectStationPicRList(stationPicR);
        return getDataTable(list);
    }


    /**
     * 导出测站实时图片列表
     */
    @RequiresPermissions("waterManagement:StationPicR:export")
    @Log(title = "测站实时图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StationPicR stationPicR)
    {
        List<StationPicR> list = stationPicRService.selectStationPicRList(stationPicR);
        ExcelUtil<StationPicR> util = new ExcelUtil<StationPicR>(StationPicR.class);
        util.exportExcel(response, list, "测站实时图片数据");
    }

    /**
     * 获取测站实时图片详细信息
     */
    @RequiresPermissions("waterManagement:StationPicR:query")
    @GetMapping(value = "/{statCd}")
    public AjaxResult getInfo(@PathVariable("statCd") String statCd)
    {
        return success(stationPicRService.selectStationPicRByStatCd(statCd));
    }

    /**
     * 新增测站实时图片
     */
    @RequiresPermissions("waterManagement:StationPicR:add")
    @Log(title = "测站实时图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StationPicR stationPicR)
    {
        return toAjax(stationPicRService.insertStationPicR(stationPicR));
    }

    /**
     * 修改测站实时图片
     */
    @RequiresPermissions("waterManagement:StationPicR:edit")
    @Log(title = "测站实时图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationPicR stationPicR)
    {
        return toAjax(stationPicRService.updateStationPicR(stationPicR));
    }

    /**
     * 删除测站实时图片
     */
    @RequiresPermissions("waterManagement:StationPicR:remove")
    @Log(title = "测站实时图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{statCds}")
    public AjaxResult remove(@PathVariable String[] statCds)
    {
        return toAjax(stationPicRService.deleteStationPicRByStatCds(statCds));
    }
}
